<?php

$mainArticlesCount = (int)$this->params['mainArticlesCount'];
$summaryArticlesCount = (int)$this->params['summaryArticlesCount'];
$linkArticlesCount = (int)$this->params['linkArticlesCount'];
$articlesCount = count($this->articles->items);

?>
<h2><?php echo $this->category->name ?></h2>
<?php if (trim($this->category->description) != '') { ?>
<p><?php echo $this->category->description ?></p>
<?php
}

if (count($this->children) > 0) {
?>
<ul>
<?php foreach ($this->children as $child) { ?>
	<li><a href="<?php echo $this->escape($child->slug) ?>"><?php echo $this->escape($child->name) ?></a></li>
<?php } ?>
</ul>
<?php
}

for ($i = 0; $i < $mainArticlesCount && $i < $articlesCount; ++$i) {
	$article = $this->articles->items[$i];
?>
<div class="article">
	<h3><a href="<?php echo $this->escape($article->url) ?>"><?php echo $this->escape($article->title) ?></a></h3>
	<p class="meta">
		Publicado por
		<a href="<?php echo $this->escape($article->authorEmail) ?>"><?php echo $this->escape($article->authorName) ?></a>,
		el <?php echo $this->escape($article->publishedAt->toString('MMMM d YYYY')) ?>
	</p>
	<div class="content"><?php echo $article->content ?></div>
	<p class="readmore"><a href="<?php echo $this->escape($article->url) ?>">Leer más... &raquo;</a></p>
</div>
<?php
}

for ($j = 0; $j < $summaryArticlesCount && $i < $articlesCount; ++$i, ++$j) {
	$article = $this->articles->items[$i];
?>
<div class="article">
	<h3><a href="<?php echo $this->escape($article->url) ?>"><?php echo $this->escape($article->title) ?></a></h3>
	<p class="meta">
		Publicado por
		<a href="<?php echo $this->escape($article->authorEmail) ?>"><?php echo $this->escape($article->authorName) ?></a>,
		el <?php echo $this->escape($article->publishedAt->toString('MMMM d YYYY')) ?>
	</p>
	<div class="content"><?php echo $this->escape($article->summary) ?></div>
	<p class="readmore"><a href="<?php echo $this->escape($article->url) ?>">Leer más... &raquo;</a></p>
</div>
<?php
}

if ($i < $articlesCount) {
?>
<ul>
<?php
	for ($j = 0; $j < $linkArticlesCount && $i < $articlesCount; ++$i, ++$j) {
		$article = $this->articles->items[$i];
?>
	<li><a href="<?php echo $this->escape($article->url) ?>"><?php echo $this->escape($article->title) ?></a></li>
<?php } ?>
</ul>
<?php } ?>
<?php echo $this->partial('_paginator.phtml', array('pagedList' => $this->articles)) ?>
